<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>组合模型</title>
</head>
<body>

</body>
<script>

    function Employee(name) {
        this.name = name;
        this.roles=['normal'];
    }

    Employee.prototype.sayHello=function () {
        alert("hello:"+this.name);
    }

    var emp1 = new Employee('Lee');
    emp1.roles.push('manager');
    console.log(emp1.roles);
    emp1.sayHello();

    var emp2 = new Employee('Martin');
    console.log(emp2.roles);
    emp2.sayHello();

</script>
</html>